#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;

class Solution1 {
public:
    int maxSubArray(vector<int>& nums) {
        int n = nums.size();
        vector<int> dp(n + 1);

        int ret = INT_MIN;
        for (int i = 1; i <= n; ++i)
        {
            dp[i] = max(nums[i - 1], dp[i - 1] + nums[i - 1]);
            ret = max(ret, dp[i]);
        }
        return ret;

    }
};

class Solution2 {
public:
    int maxSubarraySumCircular(vector<int>& nums) {
        int n = nums.size();
        vector<int> f(n + 1);
        auto g = f;
        int sum = 0, fmax = INT_MIN, gmin = INT_MAX;
        for (int i = 1; i <= n; ++i)
        {
            sum += nums[i - 1];
            f[i] = max(nums[i - 1], f[i - 1] + nums[i - 1]);
            fmax = max(fmax, f[i]);
            g[i] = min(nums[i - 1], g[i - 1] + nums[i - 1]);
            gmin = min(gmin, g[i]);
        }
        return sum == gmin ? fmax : max(sum - gmin, fmax);
    }
};

int main()
{
	return 0;
}